package com.qbccn.blog.controller;

import com.qbccn.blog.dto.ResponseCode;
import com.qbccn.blog.dto.ResponseResult;
import com.qbccn.blog.entity.BgBoard;
import com.qbccn.blog.service.CommonService;
import com.qbccn.blog.service.CountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author linke
 * @date 2019-12-22 下午 21:42
 * @description
 */
@RestController
@RequestMapping("/api/common")
public class CommonController {

    @Autowired
    private CountService countService;
    @Autowired
    private CommonService commonService;

    @GetMapping("seePage/{className}")
    public String page(@PathVariable("className") String className) {
        countService.seePage(className);
        return null;
    }

    @PostMapping("board")
    public ResponseResult board(@RequestBody BgBoard board) {
        board.setCreateTime(new Date());
        commonService.board(board);
        return new ResponseResult(ResponseCode.OK);
    }
}
